$this->mTitle->mRestrictionsLoaded = true;
wfFreeResult( $res );
} else { # oldid set, retrieve historical version
- $sql = "SELECT old_text,old_timestamp,old_user,old_flags FROM old " .
+ $sql = "SELECT old_namespace,old_title,old_text,old_timestamp,old_user,old_flags FROM old " .
"WHERE old_id={$oldid}";
$res = wfQuery( $sql, DB_READ, $fname );
- if ( 0 == wfNumRows( $res ) ) { return; }
+ if ( 0 == wfNumRows( $res ) ) {
+ return;
+ }
$s = wfFetchObject( $res );
+ if( $this->mTitle->getNamespace() != $s->old_namespace ||
+ $this->mTitle->getDBkey() != $s->old_title ) {
+ $oldTitle = Title::makeTitle( $s->old_namesapce, $s->old_title );
+ $this->mTitle = $oldTitle;
+ $wgTitle = $oldTitle;
+ }
$this->mContent = Article::getRevisionText( $s );
$this->mUser = $s->old_user;
$this->mCounter = 0;
}
$text = $this->getContent( false ); # May change mTitle by following a redirect
+
+ # Another whitelist check in case oldid or redirects are altering the title
+ if ( !$this->mTitle->userCanRead() ) {
+ $wgOut->loginToUse();
+ $wgOut->output();
+ exit;
+ }
+
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
# We're looking at an old revision
/* private */ var $mOldtext, $mNewtext;
/* private */ var $mOldUser, $mNewUser;
/* private */ var $mOldComment, $mNewComment;
+ /* private */ var $mOldPage, $mNewPage;
function DifferenceEngine( $old, $new )
{
return;
}
$wgOut->suppressQuickbar();
+
+ $oldTitle = $this->mOldPage->getPrefixedText();
+ $newTitle = $this->mNewPage->getPrefixedText();
+ if( $oldTitle == $newTitle ) {
+ $wgOut->setPageTitle( $newTitle );
+ } else {
+ $wgOut->setPageTitle( $oldTitle . ", " . $newTitle );
+ }
$wgOut->setSubtitle( wfMsg( "difference" ) );
$wgOut->setRobotpolicy( "noindex,follow" );
+ if ( !( $this->mOldPage->userCanRead() && $this->mNewPage->userCanRead() ) ) {
+ $wgOut->loginToUse();
+ $wgOut->output();
+ exit;
+ }
+
$sk = $wgUser->getSkin();
$talk = $wgLang->getNsText( NS_TALK );
$contribs = wfMsg( "contribslink" );
if ( 0 == wfNumRows( $res ) ) { return false; }
$s = wfFetchObject( $res );
+ $this->mNewPage = &$wgTitle;
$this->mNewtext = $s->cur_text;
$this->mNewUser = $s->cur_user_text;
$this->mNewComment = $s->cur_comment;
} else {
- $sql = "SELECT old_timestamp,old_text,old_flags,old_user_text,old_comment FROM old WHERE " .
+ $sql = "SELECT old_namespace,old_title,old_timestamp,old_text,old_flags,old_user_text,old_comment FROM old WHERE " .
"old_id={$this->mNewid}";
$res = wfQuery( $sql, DB_READ, $fname );
$this->mNewtext = Article::getRevisionText( $s );
$t = $wgLang->timeanddate( $s->old_timestamp, true );
+ $this->mNewPage = Title::MakeTitle( $s->old_namespace, $s->old_title );
$this->mNewtitle = wfMsg( "revisionasof", $t );
$this->mNewUser = $s->old_user_text;
$this->mNewComment = $s->old_comment;
}
if ( 0 == $this->mOldid ) {
- $sql = "SELECT old_timestamp,old_text,old_flags,old_user_text,old_comment " .
+ $sql = "SELECT old_namespace,old_title,old_timestamp,old_text,old_flags,old_user_text,old_comment " .
"FROM old USE INDEX (name_title_timestamp) WHERE " .
- "old_namespace=" . $wgTitle->getNamespace() . " AND " .
- "old_title='" . wfStrencode( $wgTitle->getDBkey() ) .
+ "old_namespace=" . $this->mNewPage->getNamespace() . " AND " .
+ "old_title='" . wfStrencode( $this->mNewPage->getDBkey() ) .
"' ORDER BY inverse_timestamp LIMIT 1";
$res = wfQuery( $sql, DB_READ, $fname );
} else {
- $sql = "SELECT old_timestamp,old_text,old_flags,old_user_text,old_comment FROM old WHERE " .
+ $sql = "SELECT old_namespace,old_title,old_timestamp,old_text,old_flags,old_user_text,old_comment FROM old WHERE " .
"old_id={$this->mOldid}";
$res = wfQuery( $sql, DB_READ, $fname );
}
if ( 0 == wfNumRows( $res ) ) { return false; }
$s = wfFetchObject( $res );
+ $this->mOldPage = Title::MakeTitle( $s->old_namespace, $s->old_title );
$this->mOldtext = Article::getRevisionText( $s );
$t = $wgLang->timeanddate( $s->old_timestamp, true );